import akshare as ak

from core.Constants import UNIT_YI


# 获得股票的静态数据
#    item               value
# 0  股票代码              000002
# 1  股票简称               万  科Ａ
# 2   总股本       11930709471.0
# 3   流通股        9716812790.0
# 4   总市值  77907532845.630005
# 5  流通市值  63450787518.700005
# 6    行业               房地产开发
# 7  上市时间            19910129

class static_info:
    def __init__(self):
        pass
    def get_stock_static_info(self,symbol):
        # 输入股票代码（如：万科A）
        df = ak.stock_individual_info_em(symbol=symbol)
        idx = df[df['item'] == '流通市值'].index[0]

        # 取出数值，除以1亿，保留2位小数
        new_value = round(float(df.at[idx, 'value']) / 1e8, 2)

        # 更新回 DataFrame
        df.at[idx, 'value'] = new_value
        # 查看结果
        return df

static_info = static_info()

if __name__ == '__main__':
    info = static_info.get_stock_static_info("600211")
    print(info)
